var map; var routeMarkerColorMode function GetMap() { // alert("into maproutearraycompositedev"); // find zoom factor from lat and lon ranges //alert("zoom = " + findLatLonVariation()); // var map; //alert("zoom factor = " + findLatLonVariation()) //var calculatedZoom = findLatLonVariation(); // var calculatedZoom = 10 // calculatedZoom = findLatLonVariation(); // calculatedZoom = 14; var calculatedZoom = parseInt(document.getElementById("txtZoom").value); /* followoing is taken out and substituted by centreMap coords var long = document.getElementById("txtLong"); var lat = document.getElementById("txtLat"); */ var long = document.getElementById("txtCentreLon"); var lat = document.getElementById("txtCentreLat"); // alert(" From start of Getmap: from document get elemnet by ID lat = " + lat.value + " long = " + long.value); //var map; map = new Microsoft.Maps.Map('#myMap', { center: new Microsoft.Maps.Location(lat.value, long.value), // center: new Microsoft.Maps.Location(52.4139239194618, -4.0500), // mapTypeId: Microsoft.Maps.MapTypeId.aerial, mapTypeId: Microsoft.Maps.MapTypeId.ordnanceSurvey, //zoom: 13}); zoom: calculatedZoom}); infobox = new Microsoft.Maps.Infobox(map.getCenter(), { visible: false }); //alert("getMap line 38 end of map definition"); //Assign the infobox to a map instance. infobox.setMap(map); /* //Create a pushpin at a random location in the map bounds. var randomLocation = Microsoft.Maps.TestDataGenerator.getLocations(1, map.getBounds()); var pin = new Microsoft.Maps.Pushpin(randomLocation); //Store some metadata with the pushpin. pin.metadata = { title: 'Pin Title', description: 'Pin description from Get map' }; //Add a click event handler to the pushpin. Microsoft.Maps.Events.addHandler(pin, 'click', pushpinClicked); //Add pushpin to the map. map.entities.push(pin); */ /* var pushpinoptions = {text: 'testing', visible: true }; var marker = new Microsoft.Maps.Pushpin(new Microsoft.Maps.Location(52.75, - 3.8), pushpinoptions); pushpinoptions = {text: 'testing', visible: true }; map.entities.push(marker); pushpinoptions = {text: 'atcentre', visible: true }; var marker2= new Microsoft.Maps.Pushpin(new Microsoft.Maps.Location(52.65, - 4), pushpinoptions); // map.entities.push(marker2 */ // map.entities.push(marker); getPushPinRouteArrayDev2(); addPolyline(); return; } function pushpinClicked(e) { //Make sure the infobox has metadata to display. if (e.target.metadata) { //Set the infobox options with the metadata of the pushpin. infobox.setOptions({ location: e.target.getLocation(), title: e.target.metadata.title, description: e.target.metadata.description, visible: true }); } } function getPushPinRouteArrayDev2() { // alert("xxxxxxxxintoPushPinRouteArrayDev2 thursday"); var long; var lat; var walkTitle; var waypointDescription; // alert("into pushpin2"); // &&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&& //insert start point try { long = document.getElementById("txtLong"); lat = document.getElementById("txtLat"); walkTitle = document.getElementById("lblWalkName").textContent; // setting up start point walkTitle = "Start"; long = parseFloat(long.value); lat = parseFloat(lat.value); // alert(" into pushpin From page text: for starting pushpin lat lon " + lat + " long " + long); var pushpinoptions = {text: 'Starting point', color: 'red', visible: true, icon: 'https://www.bingmapsportal.com/Content/images/poi_custom.png' }; pushpinoptions.text = walkTitle;; var marker = new Microsoft.Maps.Pushpin(new Microsoft.Maps.Location(lat, long), pushpinoptions); // marker.text = walkTitle; marker.metadata = { title: 'Starting Point', // description: 'Pin description' description: "should be substuted by next line" }; marker.metadata.title =( walkTitle) marker.metadata.description = routeLegDescriptionarray[0]; //Add a click event handler to the pushpin. Microsoft.Maps.Events.addHandler(marker, 'mouseover', pushpinClicked); map.entities.push(marker); } catch (ex) { alert("ex is = " + ex) } //end start point inserting ?? //&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&& try { var i; var LatString; var LonString; var LatReal; var LonReal; var iString = "iitialvalue "; var zoom = 10; //arrayLon and array description are assumed to be the same length as LatArray var routeLatArrayLength = (routeLatarray.length -1); // LatReal = parseFloat("52.4139239194618"); // LonReal = parseFloat("-4.9087"); //var pushpinoptions = {text: 'yyEnd of leg', color: 'red', visible: true, icon: 'https://www.bingmapsportal.com/Content/images/poi_custom.png' }; // var marker = new Microsoft.Maps.Pushpin(new Microsoft.Maps.Location(LatReal, LonReal), pushpinoptions); // map.entities.push(marker); i = 0; //************ trying new i start value //for (i = 0; i < routeLatArrayLength; i++) for (i = 0; i < routeLatArrayLength + 1; i++) // While(i < 5)12 { if (i == 0) { long = document.getElementById("txtLong"); lat = document.getElementById("txtLat"); walkTitle = document.getElementById("lblWalkName").textContent; waypointDescription = "Start ealk"; long = parseFloat(long.value); lat = parseFloat(lat.value); LatReal = lat; LonReal = long; //alert("latreal = " + LatReal + " LonReal = " + LonReal) ; } else { //alert("into else"); LatReal = parseFloat(routeLatarray[i - 1]); LonReal = parseFloat(routeLonarray[i -1 ]); waypointDescription = routeLegDescriptionarray[i - 1]; } //istring is the displayed leg number //******** new value // i+2 below allows for a 0 start leg + start = leg 1 iString = (i + 1).toString(); // ************* new values for lat and lon // LatReal = parseFloat(routeLatarray[i -1]); // LonReal = parseFloat(routeLonarray[i -1]); //LatReal = parseFloat(routeLatarray[i]); // LonReal = parseFloat(routeLonarray[i]); pushpinoptions = {color: 'Tomato', visible: true }; if (i < 13) {pushpinoptions.color = 'Tomato'; } pushpinoptions.text = iString; //marker.description = "XXXXXXXXXXX"; marker = new Microsoft.Maps.Pushpin(new Microsoft.Maps.Location(LatReal, LonReal), pushpinoptions); //************** trial infobox 88888888888888888888888888 //Store some metadata with the pushpin. marker.metadata = { // title: 'You are at the end of leg ' + (i + 1) + " Now follow next leg: ", title: 'You are at the start of leg ' + (i + 1) , description: 'Discription for pin' }; // marker.metadata.description = "my Nov text = " + i //**** value changed // marker.metadata.description = routeLegDescriptionarray[i - 1]; // since istring above is the leg numeber and is for i+2 below allows for a 0 start leg + start = leg 1 // then equivalent leg description array is for i + 1 since start leg does not count //********** test text inserted // marker.metadata.description = (routeLegDescriptionarray[i] + " = " + i); marker.metadata.description = (routeLegDescriptionarray[i] ); // marker.metadata.description = ("i = " + i); //Add a click event handler to the pushpin. Microsoft.Maps.Events.addHandler(marker, 'mouseover', pushpinClicked); //Add pushpin to the map. // map.entities.push(pin); //****************************************************** map.entities.push(marker); } } catch (ex) { alert("ex at end of function is is = " + ex) } // alert("leaving dev 2"); return false } function findLatLonVariation() { var i = 0; var minLat = 0; var maxLat = 0; var minLon = 0; var maxLon = 0; var latRange = 0; var lonRange = 0; var zoom = 13; var routeLatArrayLength = (routeLatarray.length -1); for (i = 0; i < routeLatArrayLength; i++) { // enter first value to provide a reference if (i == 0) { minLat = routeLatarray[i]; maxLat = parseFloat(routeLatarray[i]); minLon = parseFloat(routeLonarray[i]); maxLon = parseFloat(routeLonarray[i]); } else { // alert("into else i = " + i) if (routeLatarray[i] < minLat) { minLat = routeLatarray[i]; } if (routeLatarray[i] > maxLat) { maxLat = routeLatarray[i]; } if (routeLonarray[i] < minLon) { minLon = routeLonarray[i]; } if (routeLonarray[i] > maxLon) { maxLon = routeLonarray[i]; } } // in for loop } //in function brackets // alert("minLat = " + minLat); // alert("maxLat = " + maxLat); // alert("minLon = " + minLon); // alert("maxLon = " + maxLon); latRange = maxLat - minLat; lonRange = Math.abs(maxLon) - Math.abs(minLon); // alert("latrange = " + latRange + " lonRange = " + lonRange); if (latRange >= lonRange) { // alert(" into comparison where latRange > lonRange latrange = " + latRange + " lonRange = " + lonRange); if (latRange > .01 && latRange < .0125) { zoom = 13; if (latRange > .01 && latRange < .0125) { //findLatLonVariation() = 10; zoom = 15; } if (latRange > .0125 && latRange < .026) { //findLatLonVariation() = 10; zoom = 14; } if (latRange > .026) { //findLatLonVariation() = 10; zoom = 11; } } } if (latRange < lonRange) { // alert(" into comparison where latRange < lonRange latrange = " + latRange + " lonRange = " + lonRange); // try lonRange value of .0125 as zoom 15 if (lonRange > .01 && lonRange < .0125) { //findLatLonVariation() = 10; zoom = 15; } if (lonRange > .0125 && lonRange < .026) { //findLatLonVariation() = 10; zoom = 14; } } return zoom } function testVariation() { alert("zoomfactor from sub = " + findLatLonVariation()); return } function addPolyline() { //alert("into addPolyline{} maproutearraycompositedev"); /* ************************************** * this function takes the routeCoordsArray created by the 'getLatLonCoordinates' routine then produces the polygon location array for pushing onto the map ************************************** */ // var coordinates = ["44.084096,-80.417484", "44.633935,-77.462162", "42.452304, -78.879398","52.3063981184,-4.1447174417","52.3066874381,-4.1448781331","52.3067323586,-4.1448803065","52.3067766132,-4.1449191213","52.3075711935,-4.1457277266" ,"52.3075420696,-4.1460930590"]; // var coordinates = ["52.3063981184,-4.1447174417","52.3066874381,-4.1448781331","52.3067323586,-4.1448803065","52.3067766132,-4.1449191213","52.3075711935,-4.1457277266" ,"52.3075420696,-4.1460930590","52.3075420696, -4.1463205229", "52.3076952928,-4.1463205229" , "52.3083170462,-4.1455071059","52.3087068649,-4.1450858715", "52.3090253051,-4.1448812289", "52.3092069854 ,-4.1447799932", "52.3094057976,-4.1449729915", "52.3098054195 ,-4.1452490619"]; //var coordinates = ["52.3063981184,-4.1447174417", "52.3066874381,-4.1448781331"]; //, "52.3067323586,-4.1448803065","52.3067766132,-4.1449191213", "52.3075711935,-4.1457277266" , "52.3075420696,-4.1460930590"]; // alert("into polyine function"); var locs = []; // alert("routeCoordsArray.length = " + routeCoordsArray.length); // for (i = 0; i < 60; i++) { for (i = 0; i < routeCoordsArray.length; i++) { locs.push(Microsoft.Maps.Location.parseLatLong(routeCoordsArray[i])); } // alert("just before red definition for color"); var polyline = new Microsoft.Maps.Polyline(locs, null); /* polyline.setOptions({strokeColor: 'red', strokeThickness: 10}); */ //var routeColor = new Microsoft.Maps.Color(175, 208, 158, 226); var routeColor = new Microsoft.Maps.Color( 125, 0,102,204); polyline.setOptions({ //strokeColor: 'darkorchid', strokeColor: routeColor, strokeThickness: 10 }); map.entities.push(polyline); //"52.3063981184,-4.1447174417" ,"52.3066874381,-4.1448781331, ,"52.3067323586,-4.1448803065" ,"52.3067766132,-4.1449191213", "52.3075711935,-4.1457277266" , "52.3075420696, -4.1460930590" } function routePhotos(strTemp){ //sqlgenerator window.open(strTemp, '_blank', 'toolbar=no,resizable=yes, scrollbars=yes,width=500,height=600'); } //src = 'https://www.bing.com/api/maps/mapcontrol?key=Ah3tk0hDo7O4nB6B36mbzMF7CCd3gCp6V8cUTlnp3jzl3CtrMjANVfrNv8SRmDx6';